''' 
 Created on 2009-10-22 
  
 @author: summit 
 ''' 
import wx 
import wx.aui 
  
from jolly.tvisual.PythonViewImage2D import * 
from jolly.visual.vtkPythonViewImageCollection import * 
from jolly.visual.vtkPythonViewImage2D import * 
from jolly.visual.vtkPythonViewImage3D import * 
  
from jolly.wxext.wxVTKPageView import * 
  
from jolly.tvisual.PythonViewImage3D import * 
from jolly.datamanagement.vtkPythonMetaImageData  import *


  
class Yuki(wx.Frame): 
    ''' 
    classdocs 
    ''' 
    __viewxy=None 
    __viewyz=None 
    __viewxz=None 
    __view3D=None 
      
    __configurexyPanel=None 
    __configureyzPanel=None 
    __configurexzPanel=None 
    __configure3DPanel=None 
      
    __viewtraitsxy=None 
    __viewtraitsyz=None 
    __viewtraitsxz=None 
    __viewtraits3D=None 
     
    __vtkpageview=None 
     
    __viewcollection=None 
      
      
    def __init__(self, parent, id=wx.ID_ANY, title="", pos= wx.DefaultPosition, 
                  size=wx.DisplaySize(), style=wx.DEFAULT_FRAME_STYLE|wx.SUNKEN_BORDER): 
        ''' 
        Constructor 
        ''' 
        wx.Frame.__init__(self, parent, id, title, pos, size, style) 
        
        image = vtkPythonMetaImageData()
        image.ReadSeriesFile("C:\S70")
        imagedata = image.getDataSet()
    
        self.__vtkpageview=wxVTKPageView(self, wx.ID_ANY) 
        self.__viewcollection = vtkPythonViewImageCollection() 
       
        
        self.__view3D = vtkPythonViewImage3D() 
        self.__viewcollection.AddItem(self.__view3D) 
          
        self.__viewxy = vtkPythonViewImage2D() 
        self.__viewxy.SetInput(imagedata) 
        self.__viewxy.GlobalWarningDisplayOff() 
        
        self.__viewtraitsxy = PythonViewImage2D(self.__viewxy) 
        self.__viewtraitsxy.set_observer(self.__viewcollection) 
        self.__configurexyPanel = pythonviewimage2d_view 
        
        self.__viewxy.SetupInteractor(self.__vtkpageview.viewInteractor1) 
        self.__viewxy.SetRenderWindow(self.__vtkpageview.viewInteractor1.GetRenderWindow()) 
        self.__viewxy.SetInteractorStyleTypeToNavigation() 
        self.__viewxy.SetSliceOrientationToXY() 
        self.__view3D.Add2DPhantom(self.__viewxy.GetImageActor()) 
        self.__viewcollection.AddItem(self.__viewxy) 
       
         
        self.__viewyz = vtkPythonViewImage2D() 
        self.__viewyz.SetInput(imagedata) 
        self.__viewyz.GlobalWarningDisplayOff() 
        self.__viewtraitsyz = PythonViewImage2D(self.__viewyz) 
        self.__viewtraitsyz.set_observer(self.__viewcollection) 
        self.__configureyzPanel = pythonviewimage2d_view 
        
        self.__viewyz.SetupInteractor(self.__vtkpageview.viewInteractor2) 
        self.__viewyz.SetRenderWindow(self.__vtkpageview.viewInteractor2.GetRenderWindow()) 
        self.__viewyz.SetInteractorStyleTypeToNavigation() 
        self.__viewyz.SetSliceOrientationToYZ() 
        self.__viewcollection.AddItem(self.__viewyz) 
        self.__view3D.Add2DPhantom(self.__viewyz.GetImageActor()) 
       
        
        self.__viewxz = vtkPythonViewImage2D() 
        self.__viewxz.SetInput(imagedata) 
        self.__viewxz.GlobalWarningDisplayOff() 
        
        self.__viewtraitsxz = PythonViewImage2D(self.__viewxz) 
        self.__viewtraitsxz.set_observer(self.__viewcollection) 
        self.__configurexzPanel = pythonviewimage2d_view 
        
        self.__viewxz.SetupInteractor(self.__vtkpageview.viewInteractor3) 
        self.__viewxz.SetRenderWindow(self.__vtkpageview.viewInteractor3.GetRenderWindow()) 
        self.__viewxz.SetInteractorStyleTypeToNavigation() 
        self.__viewxz.SetSliceOrientationToXZ() 
        self.__viewcollection.AddItem(self.__viewxz) 
        self.__view3D.Add2DPhantom(self.__viewxz.GetImageActor()) 
       
          
         
        self.__view3D.SetInput(imagedata) 
        self.__view3D.GlobalWarningDisplayOff() 
        
        self.__viewtraits3D = PythonViewImage3D(self.__view3D) 
        self.__viewtraits3D.set_observer(self.__viewcollection) 
        self.__configure3DPanel = pythonviewimage3d_view 
        
        self.__view3D.SetupInteractor(self.__vtkpageview.viewInteractor4) 
        self.__view3D.SetRenderWindow(self.__vtkpageview.viewInteractor4.GetRenderWindow()) 
        self.__view3D.SetRenderingModeToVR() 
        self.__view3D.InstallPipeline() 
       
          
        self.__mgr = wx.aui.AuiManager() 
        self.__mgr.SetFlags(wx.aui.AUI_MGR_RECTANGLE_HINT or wx.aui.AUI_MGR_ALLOW_ACTIVE_PANE ) 
        self.__mgr.SetManagedWindow(self) 
        self.DoLayout() 
        
        
        
#        self.__viewxy.SetInput(imagedata)
#        self.__viewyz.SetInput(imagedata)
#        self.__viewxz.SetInput(imagedata)
#        self.__viewcollection.InstallCrossAxes()
#        self.__viewcollection.SyncReset()
#        self.__viewcollection.SyncRender()
    
    def AttachView(self):
        self.__viewxy.SetupInteractor(self.__vtkpageview.viewInteractor1) 
        self.__viewxy.SetRenderWindow(self.__vtkpageview.viewInteractor1.GetRenderWindow()) 
        self.__view3D.SetupInteractor(self.__vtkpageview.viewInteractor4) 
        self.__view3D.SetRenderWindow(self.__vtkpageview.viewInteractor4.GetRenderWindow()) 
        self.__viewyz.SetupInteractor(self.__vtkpageview.viewInteractor2) 
        self.__viewyz.SetRenderWindow(self.__vtkpageview.viewInteractor2.GetRenderWindow()) 
        self.__viewxz.SetupInteractor(self.__vtkpageview.viewInteractor3) 
        self.__viewxz.SetRenderWindow(self.__vtkpageview.viewInteractor3.GetRenderWindow()) 
     
      
    def DoLayout(self): 
        self.__mgr.AddPane(self.CreateConfigureNoteBook(), wx.aui.AuiPaneInfo().Name("configure_panel").Caption("configure"). 
                           Left().Layer(1).Position(1).CloseButton(True).MaximizeButton(True). 
                           MinimizeButton(True).MinimizeButton(True)) 
        self.__mgr.AddPane(self.__vtkpageview, wx.aui.AuiPaneInfo().Name("PageView").Caption("PageView").CenterPane().PaneBorder(False)) 
        self.__mgr.Update() 
          
    def CreateConfigureNoteBook(self): 
        client_size = self.GetClientSize() 
        ctrl = wx.aui.AuiNotebook(self, -1, wx.Point(0, 0), wx.Size(160, 250),  
                               wx.aui.AUI_NB_DEFAULT_STYLE | wx.aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER) 
  
        ctrl.AddPage(self.__configurexyPanel.ui(parent=ctrl, context=self.__viewtraitsxy).control, "xy configure") 
        ctrl.AddPage(self.__configureyzPanel.ui(parent=ctrl, context=self.__viewtraitsyz).control, "yz configure") 
        ctrl.AddPage(self.__configurexzPanel.ui(parent=ctrl, context=self.__viewtraitsxz).control, "xz configure") 
        ctrl.AddPage(self.__configure3DPanel.ui(parent=ctrl, context=self.__viewtraits3D).control, "3D configure") 
        return ctrl 
    
    def getViewcollection(self):
        return self.__viewcollection
    
    def getViewxy(self): 
        return self.__viewxy 
  
  
    def getViewyz(self): 
        return self.__viewyz 
  
  
    def getViewxz(self): 
        return self.__viewxz 
  
  
    def getView3D(self): 
        return self.__view3D 
  
  
    def setViewxy(self, value): 
        self.__viewxy = value 
  
  
    def setViewyz(self, value): 
        self.__viewyz = value 
  
  
    def setViewxz(self, value): 
        self.__viewxz = value 
  
  
    def setView3D(self, value): 
        self.__view3D = value 
  
  
    def delViewxy(self): 
        del self.__viewxy 
  
  
    def delViewyz(self): 
        del self.__viewyz 
  
  
    def delViewxz(self): 
        del self.__viewxz 
  
  
    def delView3D(self): 
        del self.__view3D 
  
    viewxy = property(getViewxy, setViewxy, delViewxy, "Viewxy's Docstring") 
  
    viewyz = property(getViewyz, setViewyz, delViewyz, "Viewyz's Docstring") 
  
    viewxz = property(getViewxz, setViewxz, delViewxz, "Viewxz's Docstring") 
  
    view3D = property(getView3D, setView3D, delView3D, "View3D's Docstring") 
  
  
if __name__ == '__main__': 
    
    
    app = wx.PySimpleApp() 
    frame = Yuki(None) 
    frame.Show(True) 
    
    
    
    
    app.MainLoop() 
    
